﻿//-----------------------------------------------------------------------
// <copyright file="ActionTest.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings
using System;
using FastNET.CleanAct.Common.Repository.Interfaces.DataInterfaces.ManagementEngine;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Action = FastNET.CleanAct.Client.ManagerEngineData.Entities.Action;
#endregion

namespace FastNET.CleanAct.Testing.Client.ManagerEngineData.Entities
{
    /// <summary>
    /// Unit Tests for ActionTest
    /// </summary>
    [TestClass]
    public class ActionTest
    {
        /// <summary>
        /// Gets or sets the test context which provides
        /// information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext { get; set; }

        #region ActionType Validation

        /// <summary>
        /// Test for ActionType being Null
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ActionType_Null()
        {
            new Action { ActionType = null };
        }

        /// <summary>
        /// Test for ActionType being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void ActionType_TooLong()
        {
            new Action { ActionType = string.Empty.PadRight(101, 'A') };
        }

        /// <summary>
        /// Test for ActionType being successful
        /// </summary>
        [TestMethod]
        public void ActionType_Success()
        {
            IActionData data = new Action { ActionType = "TestName" };
            Assert.AreEqual("TestName", data.ActionType, "Mismatched Data");
        }

        /// <summary>
        /// Test for ActionType being defaulted
        /// </summary>
        [TestMethod]
        public void ActionType_Default()
        {
            IActionData data = new Action();
            Assert.AreEqual(null, data.ActionType, "Mismatched Data");
        }

        #endregion

        #region Pattern Validation

        /// <summary>
        /// Test for Pattern being Null
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Pattern_Null()
        {
            new Action { Pattern = null };
        }

        /// <summary>
        /// Test for Pattern being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Pattern_TooLong()
        {
            new Action { Pattern = string.Empty.PadRight(4001, 'A') };
        }

        /// <summary>
        /// Test for Pattern being successful
        /// </summary>
        [TestMethod]
        public void Pattern_Success()
        {
            IActionData data = new Action { Pattern = "TestName" };
            Assert.AreEqual("TestName", data.Pattern, "Mismatched Data");
        }

        /// <summary>
        /// Test for Pattern being defaulted
        /// </summary>
        [TestMethod]
        public void Pattern_Default()
        {
            IActionData data = new Action();
            Assert.AreEqual(null, data.Pattern, "Mismatched Data");
        }

        #endregion

        #region Name Validation

        /// <summary>
        /// Test for Name being Null
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Name_Null()
        {
            new Action { Name = null };
        }

        /// <summary>
        /// Test for Name being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Name_TooLong()
        {
            new Action { Name = string.Empty.PadRight(101, 'A') };
        }

        /// <summary>
        /// Test for Name being successful
        /// </summary>
        [TestMethod]
        public void Name_Success()
        {
            IActionData data = new Action { Name = "TestName" };
            Assert.AreEqual("TestName", data.Name, "Mismatched Data");
        }

        /// <summary>
        /// Test for Name being defaulted
        /// </summary>
        [TestMethod]
        public void Name_Default()
        {
            IActionData data = new Action();
            Assert.AreEqual(null, data.Name, "Mismatched Data");
        }

        #endregion

        #region RecursiveMode Validation

        /// <summary>
        /// Test for RecursiveMode being successful
        /// </summary>
        [TestMethod]
        public void RecursiveMode_Success()
        {
            IActionData data = new Action { RecursiveMode = 10 };
            Assert.AreEqual(10, data.RecursiveMode, "Mismatched Data");
        }

        /// <summary>
        /// Test for RecursiveMode being defaulted
        /// </summary>
        [TestMethod]
        public void RecursiveMode_Default()
        {
            IActionData data = new Action();
            Assert.AreEqual(0, data.RecursiveMode, "Mismatched Data");
        }

        #endregion
    }
}
